﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RATSharp.Model;
using System.Threading.Tasks;
using RATSharp.Rest;
using System.Runtime.Serialization;

namespace RATSharpW7.ViewModel
{
    [DataContract]
    public class EditPeriodViewModel : PeriodViewModel
    {
        public EditPeriodViewModel(period per) : base(per, null)
        {
        }

        /// <summary>
        /// this method is overriden because we want to edit reservation, not to create a new one
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="period"></param>
        protected override void modifyPeriod(EventHandler<ModifyReservationEventArgs> handler, period period)
        {
           Task<Reservations> task = RestService.getInstance().modifyPeriod(period.id.Value, period.FromDate, period.ToDate, period.Valid);
           notifyChangeModel(task, handler);
        }

        /// <summary>
        /// Delete whole DataSource reservation
        /// </summary>
        /// <param name="handler">Rest Handler</param>
        public void deleteReservation(EventHandler<ModifyReservationEventArgs> handler)
        {
            Task<Reservations> task = RestService.getInstance().deleteReservation(DataSource.reservation);
            notifyChangeModel(task, handler);
        }
    }
}
